{if $error != ""}
	<p><span class="error"> {$error} </span></p>
{/if}

<form name="gamesForm" method = "POST" action = "">
	{if isset($leagueId)}
		<input type="Hidden" name="leagueId" value="{$leagueId}" />
	{else}
		Lig: 
		{foreach from=$leagues key=myId item=i name=leagueT}
			{if $smarty.foreach.leagueT.first}
				<select name="leagueId">
			{/if}
	
		  	<option value="{$i->id}">{$i->league}</option>
			{if $smarty.foreach.leagueT.last}
				</select> 
			{/if}
		{/foreach}		
	{/if}
	{if isset($game->day)}
		<br/>Hafta: <input type="text" name="day" value='{$game->day}' />
	{else}
		<br/>Hafta: <input type="text" name="day" value='{$day}' />
	{/if}
	{if isset($game->date)}
		<br />Tarih: <input type="text" name="date" value='{$game->date|date_format:"%Y-%m-%d"}' />
	{elseif isset($date)}
		<br />Tarih: <input type="text" name="date" value='{$date|date_format:"%Y-%m-%d"}' />
	{else}
		<br />Tarih: <input type="text" name="date" value='{$game_date|date_format:"%Y-%m-%d"}' />
	{/if}
	{literal}
	<script language="JavaScript">
	new tcal ({
		// form name
		'formname': 'gamesForm',
		// input name
		'controlname': 'date'
	});
	</script>
	{/literal}
	<br/>Saat: {html_select_time use_24_hours=true display_seconds=no minute_interval=15 time=$game_date}
	
	<br />Ev Sahibi:
		{foreach from=$teams key=myId item=i name=teamT}
			{if $smarty.foreach.teamT.first}
				<select name="home_team_id">
			{/if}
			  {if ($game->home_team->id == $i->id)}
			  	<option value="{$i->id}" selected="selected">{$i->team}</option>
			  {else}
			  	<option value="{$i->id}">{$i->team}</option>
			  {/if}
			{if $smarty.foreach.teamT.last}
				</select> 
			{/if}
		{/foreach}
	<br />Konuk:
		{foreach from=$teams key=myId item=i name=teamT}
			{if $smarty.foreach.teamT.first}
				<select name="away_team_id">
			{/if}
			  {if $game->away_team->id == $i->id}
			  	<option value="{$i->id}" selected="selected">{$i->team}</option>
			  {else}
			  	<option value="{$i->id}">{$i->team}</option>
			  {/if}
			{if $smarty.foreach.teamT.last}
				</select> 
			{/if}
		{/foreach}	
		
	{if $action == "Form" && $id != ""}
	    <input type="hidden" name="id" value="{$id}" />
		<br /><input type="Submit" name="action" value="Update" title="Degistir" />
	{else}
		<br /><input type="Submit" name="action" value="Add" title="Ekle"/>
	{/if}
</form>